package com.ych.modules.cms.authorInfc.chargeRule.controller;

import com.ych.modules.base.dbEntity.TSysChargeRuleEntity;
import com.ych.modules.base.service.ITSysChargeRuleService;
import com.ych.utils.serviceReturn.R;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * Created with IntelliJ IDEA.
 * Author: Usopp.tsui
 * Date: 2021/3/18
 * Time: 14:59
 * Description:
 */
@Api(tags = {"CMS--收费业务收费规则配置相关"}, description = "CMS--收费业务收费规则配置相关")
@RestController
@RequestMapping("/cms/auth/charge/rule")
public class ChargeRuleController {
    @Autowired
    private ITSysChargeRuleService itSysChargeRuleService;

    @ApiOperation(value = "获取收费规则列表", position = 1)
    @PostMapping("/listChargeRule")
    public R<List<TSysChargeRuleEntity>> listChargeRule() {
        try {
            List<TSysChargeRuleEntity> list = itSysChargeRuleService.listChargeRule();
            return new R(0, "成功", list);
        } catch (Exception e) {
            return new R(1, e.getMessage(), null);
        }
    }

    @ApiOperation(value = "修改收费规则", position = 1)
    @GetMapping("/modifyChargeRule")
    public R<String> modifyChargeRule(@RequestBody TSysChargeRuleEntity entity) {
        try {
            itSysChargeRuleService.modifyChargeRule(entity);
            return new R(0, "成功", null);
        } catch (Exception e) {
            return new R(1, e.getMessage(), null);
        }
    }
}
